﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using Autorent.Desktop.Views;
using Autorent.Desktop.ViewModels;

namespace Autorent.Desktop
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            this.Resources.MergedDictionaries.Clear();
            string packUri = @"/Autorent.Desktop.Themes;component/Themes/MainTheme.xaml";
            var resourceDictionary = Application.LoadComponent(new Uri(packUri, UriKind.Relative)) as ResourceDictionary;
            this.Resources.MergedDictionaries.Add(resourceDictionary);

            this.ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose;

            LoginView view = new LoginView();
            LoginViewModel model = new LoginViewModel(view);

            this.MainWindow = null;

            if (view.ShowDialog() != true)
            {
                this.Shutdown();
            }
            else
            {
                Bootstrapper bootstrapper = new Bootstrapper();
                bootstrapper.Run();
            }
        }
    }
}
